﻿using System.Text.Json.Serialization;

namespace Xms.Abp.Data;

[Serializable]
public abstract class ExtensibleEntityResult<TKey> : ExtensibleObject, IEntityResult<TKey>
{
    [Display(Name = "主键")]
    public TKey Id { get; set; }

    public override string ToString()
    {
        return $"[DTO: {GetType().Name}] Id = {Id}";
    }
}

[Serializable]
public abstract class ExtensibleEntityResult : ExtensibleObject, IEntityResult
{
    public override string ToString()
    {
        return $"[DTO: {GetType().Name}]";
    }
}

[Serializable]
public class ExtensibleObject : IHasExtraProperties
{
    [JsonInclude]
    [Display(Name = "扩展属性")]
    public ExtraPropertyDictionary ExtraProperties { get; protected set; }

    public ExtensibleObject()
    {
        ExtraProperties = new ExtraPropertyDictionary();
    }
}

[Serializable]
public class ExtraPropertyDictionary : Dictionary<string, object>
{
    public ExtraPropertyDictionary()
    {

    }

    public ExtraPropertyDictionary(IDictionary<string, object> dictionary)
        : base(dictionary)
    {
    }
}
public interface IHasExtraProperties
{
    ExtraPropertyDictionary ExtraProperties { get; }
}
